﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AssignmentKPI.aspx.cs"
    Inherits="FBKPI.Forms.AssignmentKPI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript">
        $(document).ready(function () {

            //alert($('#<%= hfIdAssign.ClientID %>').val());

            $("#divBrowseBusinessGroup").hide();
            $("#divBrowseRGMType").hide();
            $("#divBrowseBusinessGroup").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });
            $("#divBrowseRGMType").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });

            $("#divBrowseRGM").hide();
            $("#divBrowseRGM").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });

            $("#divBrowseLocation").hide();
            $("#divBrowseLocation").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });

            $("#divBrowseSubBranch").hide();
            $("#divBrowseSubBranch").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });

            $("#divBrowseDivision").hide();
            $("#divBrowseDivision").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });

            $("#divBrowseDepartment").hide();
            $("#divBrowseDepartment").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });

            

            var jmlGroup = $("#hfIdDetail").val();
            if (jmlGroup != "0") {
                var handlerUrl = '<%= ResolveUrl("~/ProcessRequest/KPIAssignmentHandler.ashx") %>';
                var KpiID = $('#<%= hfIdAssign.ClientID %>').val(); // $("#hfId").val();
                var counterID = 0;
                $.ajax({
                    type: 'POST',
                    url: handlerUrl + "?method=GroupAssigmentByKpiID&KpiID=" + KpiID,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        $.each(datas, function (i, data) {
                            var html = "<tr id='1" + counterID + "'><td>" + data.NameGroup + "</td><td>&nbsp;<a onclick='hapusrowBussines(1" + counterID + ")' href='#'>remove</a></td><td> <input type='hidden' name='1" + counterID + "' id='1" + counterID + "' value='" + data.IdAssignKPI + "' /></td></tr>";
                            $("#tblAssignment").append(html);
                            counterID++;

                        });

                    },
                    error: function () {
                        alert('Error load group !');
                    }
                });

            }

            var jmlGroupDua = $("#hfIdDetailDua").val();
            if (jmlGroupDua != "0") {
                var handlerUrl = '<%= ResolveUrl("~/ProcessRequest/KPIAssignmentHandler.ashx") %>';
                var KpiID = $('#<%= hfIdAssign.ClientID %>').val(); // $("#hfId").val();
                var counterIDDua = 0;
                $.ajax({
                    type: 'POST',
                    url: handlerUrl + "?method=GroupAssigmentByKpiIDDua&KpiID=" + KpiID,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        $.each(datas, function (i, data) {
                            var html = "<tr id='2" + counterIDDua + "'><td>" + data.NameGroup + "</td><td>&nbsp;<a onclick='hapusrowAssignmentDua(2" + counterIDDua + ")' href='#'>remove</a></td><td> <input type='hidden' name='2" + counterIDDua + "' id='2" + counterIDDua + "' value='" + data.IdAssignKPI + "' /></td></tr>";
                            $("#tblAssignmentDua").append(html);
                            counterIDDua++;

                        });

                    },
                    error: function () {
                        alert('Error load group !');
                    }
                });

            }

            $('#ddlAssigment').change(function () {
                $('#tblAssignment tr').remove();
            });

            $('#ddlAssignmentDua').change(function () {
                $('#tblAssignmentDua tr').remove();
            });

            $("#btn_saveassign").click(function () {

                var counterGroupID = 0;
                var GroupIdValue = "";
                $('#tblAssignment tr').each(function () {
                    var GroupID = $('[name=1' + counterGroupID + ']').val();
                    GroupIdValue += GroupID + "|";
                    counterGroupID++;
                });

                var counterGroupIDDua = 0;
                var GroupIdValueDua = "";
                $('#tblAssignmentDua tr').each(function () {
                    var GroupIDDua = $('[name=2' + counterGroupIDDua + ']').val();
                    GroupIdValueDua += GroupIDDua + "|";
                    counterGroupIDDua++;
                });
               

                var groupID = $("#ddlAssigment").val();
                var groupIDDua = $("#ddlAssignmentDua").val();
                var param = "?method=Save";
                param = param + "&ID=" + $('#<%= hfIdAssign.ClientID %>').val();
                param = param + "&groupID=" + groupID;
                param = param + "&groupIDDua=" + groupIDDua;
                param = param + "&IdAssignKPI=" + GroupIdValue;
                param = param + "&IdAssignKPIDua=" + GroupIdValueDua;

                //alert($('#<%= hfIdAssign.ClientID %>').val());


                //                param = param + "&RgmTypeID=" + RgmTypeIDValue;
                //                param = param + "&RgmID=" + RgmIDValue;
                //                param = param + "&BranchID=" + BranchIDValue;
                param = param + "&CurrUser=" + $("#txt_user").val();
                ProcessRequest("KPIAssignmentHandler.ashx" + param, "#divdetailAssign", "#KPITable");


                return false;
            });

            $("#btn_closeassign").click(function () {
                parent.$("#divdetailAssign").dialog("close");
                return false;
            });


            $("#btn_delete").click(function () {
                //                if (confirm('Are you sure to delete this record?')) {
                //                    var param = "?";
                //                    param = param + "action=delete";
                //                    param = param + "&ID=" + $("#txt_id").val();
                //                    param = param + "&CurrUser=" + $("#txt_user").val();
                //                    ProcessRequest("RGMHandler.ashx" + param, "#divdetail", "#RGMTable");
                //                    return false;
                //                }

                $.msgBox.confirm("Benar data akan dihapus ?", function () {
                    var param = "?";
                    param = param + "action=delete";
                    param = param + "&ID=" + $("#txt_id").val();
                    param = param + "&CurrUser=" + $("#txt_user").val();
                    ProcessRequest("RGMHandler.ashx" + param, "#divdetail", "#RGMTable");
                    return false;
                }, false);

                return false;
            });

            $("#btn_BrowseBusinessGroupDua").click(function () {
                var ddlType = $("#ddlAssignmentDua").val();
                if (ddlType == "6") {
                    $("#divBrowseDivision").dialog("option", "title", '<span class="header-text">Select Division</span>');
                    $("#divBrowseDivision").dialog("open");
                    $('#division').dataTable({
                        "oLanguage": {
                            "sZeroRecords": "No records to display",
                            "sSearch": "Search"
                        },
                        "bSort": false,
                        "bPaginate": true,
                        "bAutoWidth": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bDestroy": true,
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bDeferRender": true,
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            $.ajax({
                                "dataType": 'json',
                                "type": "GET",
                                "url": "../Serializer/DivisionSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                                "data": aoData,
                                "success": fnCallback
                            });
                        },
                        "aoColumns": [
                        { "mData": "No" },
                        { "mData": "Description" },
                        { "mData": "isActive" },
                        { "mData": "ID" }
                    ],
                        "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickDivision('" + oObj.aData["ID"] + "','" + oObj.aData["Description"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [3]
                        },
                        { "sClass": "center", "aTargets": [0, 2, 3] },
                        { "fnRender":
                            function (oObj) {
                                if (oObj.aData["isActive"] == 'True') {
                                    return "<img src='../images/check.png' />"
                                }
                                else {
                                    return "<img src='../images/cross.png' />"
                                }
                            },
                            "aTargets": [2]
                        }
                    ]
                    });

                    //mark selected row
                    $('body').on("click", '#division tbody tr', function () {
                        $('#division tbody tr').removeClass("row_selected");
                        $(this).addClass("row_selected");
                    });
                    $(".dataTables_filter input").focus();

                }
                else {
                    $("#divBrowseDepartment").dialog("option", "title", '<span class="header-text">Select Department</span>');
                    $("#divBrowseDepartment").dialog("open");
                    $('#department').dataTable({
                        "oLanguage": {
                            "sZeroRecords": "No records to display",
                            "sSearch": "Search"
                        },
                        "bSort": false,
                        "bPaginate": true,
                        "bAutoWidth": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bDestroy": true,
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bDeferRender": true,
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            $.ajax({
                                "dataType": 'json',
                                "type": "GET",
                                "url": "../Serializer/DepartmentSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                                "data": aoData,
                                "success": fnCallback
                            });
                        },
                        "aoColumns": [
                        { "mData": "No" },
                        { "mData": "Description" },
                        { "mData": "isActive" },
                        { "mData": "ID" }
                    ],
                        "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickDepartment('" + oObj.aData["ID"] + "','" + oObj.aData["Description"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [3]
                        },
                        { "fnRender":
                            function (oObj) {
                                if (oObj.aData["isActive"] == 'True') {
                                    return "<img src='../images/check.png' />"
                                }
                                else {
                                    return "<img src='../images/cross.png' />"
                                }
                            },
                            "aTargets": [2]
                        },
                        { "sClass": "center", "aTargets": [0, 2, 3] }
                    ]
                    });

                    //mark selected row
                    $('body').on("click", '#department tbody tr', function () {
                        $('#department tbody tr').removeClass("row_selected");
                        $(this).addClass("row_selected");
                    });
                    $(".dataTables_filter input").focus();
                }

                return false;
            });

            $("#btn_BrowseBusinessGroup").click(function () {
                var ddlType = $("#ddlAssigment").val();

                if (ddlType == "1") {
                    $("#divBrowseBusinessGroup").dialog("option", "title", '<span class="header-text">Select Business Group</span>');
                    $("#divBrowseBusinessGroup").dialog("open");
                    $('#businessgroup').dataTable({
                        "oLanguage": {
                            "sZeroRecords": "No records to display",
                            "sSearch": "Search"
                        },
                        "bSort": false,
                        "bPaginate": true,
                        "bAutoWidth": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bDestroy": true,
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bDeferRender": true,
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            $.ajax({
                                "dataType": 'json',
                                "type": "GET",
                                "url": "../Serializer/BusinessGroupSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                                "data": aoData,
                                "success": fnCallback
                            });
                        },
                        "aoColumns": [
                        { "mData": "No" },
                        { "mData": "Description" },
                        { "mData": "isActive" },
                        { "mData": "ID" }
                    ],
                        "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickBusinessGroup('" + oObj.aData["ID"] + "','" + oObj.aData["Description"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [3]
                        },
                        { "sClass": "center", "aTargets": [0, 2, 3] },
                        { "fnRender":
                            function (oObj) {
                                if (oObj.aData["isActive"] == 'True') {
                                    return "<img src='../images/check.png' />"
                                }
                                else {
                                    return "<img src='../images/cross.png' />"
                                }
                            },
                            "aTargets": [2]
                        }
                    ]
                    });

                    //mark selected row
                    $('body').on("click", '#businessgroup tbody tr', function () {
                        $('#businessgroup tbody tr').removeClass("row_selected");
                        $(this).addClass("row_selected");
                    });
                    $(".dataTables_filter input").focus();
                }
                else if (ddlType == "2") {
                    $("#divBrowseRGMType").dialog("option", "title", '<span class="header-text">Select RGM Type</span>');
                    $("#divBrowseRGMType").dialog("open");
                    $('#rgmtype').dataTable({
                        "oLanguage": {
                            "sZeroRecords": "No records to display",
                            "sSearch": "Search"
                        },
                        "bSort": false,
                        "bPaginate": true,
                        "bAutoWidth": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bDestroy": true,
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bDeferRender": true,
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            $.ajax({
                                "dataType": 'json',
                                "type": "GET",
                                "url": "../Serializer/RGMTypeSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                                "data": aoData,
                                "success": fnCallback
                            });
                        },
                        "aoColumns": [
                        { "mData": "No" },
                        { "mData": "Description" },
                        { "mData": "isActive" },
                        { "mData": "ID" }
                    ],
                        "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickRGMType('" + oObj.aData["ID"] + "','" + oObj.aData["Description"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [3]
                        },
                        { "sClass": "center", "aTargets": [0, 2, 3] },
                        { "fnRender":
                            function (oObj) {
                                if (oObj.aData["isActive"] == 'True') {
                                    return "<img src='../images/check.png' />"
                                }
                                else {
                                    return "<img src='../images/cross.png' />"
                                }
                            },
                            "aTargets": [2]
                        }
                    ]
                    });

                    //mark selected row
                    $('body').on("click", '#rgmtype tbody tr', function () {
                        $('#rgmtype tbody tr').removeClass("row_selected");
                        $(this).addClass("row_selected");
                    });
                    $(".dataTables_filter input").focus();
                }
                else if (ddlType == "3") {
                    $("#divBrowseRGM").dialog("option", "title", '<span class="header-text">Select RGM</span>');
                    $("#divBrowseRGM").dialog("open");
                    $('#rgm').dataTable({
                        "oLanguage": {
                            "sZeroRecords": "No records to display",
                            "sSearch": "Search"
                        },
                        "bSort": false,
                        "bPaginate": true,
                        "bAutoWidth": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bDestroy": true,
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bDeferRender": true,
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            $.ajax({
                                "dataType": 'json',
                                "type": "GET",
                                "url": "../Serializer/RGMSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                                "data": aoData,
                                "success": fnCallback
                            });
                        },
                        "aoColumns": [
                        { "mData": "No" },
                        { "mData": "Description" },
                        { "mData": "isActive" },
                        { "mData": "ID" }
                    ],
                        "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickRGM('" + oObj.aData["ID"] + "','" + oObj.aData["Description"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [3]
                        },
                        { "sClass": "center", "aTargets": [0, 2, 3] },
                        { "fnRender":
                            function (oObj) {
                                if (oObj.aData["isActive"] == 'True') {
                                    return "<img src='../images/check.png' />"
                                }
                                else {
                                    return "<img src='../images/cross.png' />"
                                }
                            },
                            "aTargets": [2]
                        }
                    ]
                    });

                    //mark selected row
                    $('body').on("click", '#rgm tbody tr', function () {
                        $('#rgm tbody tr').removeClass("row_selected");
                        $(this).addClass("row_selected");
                    });
                    $(".dataTables_filter input").focus();
                }
                else if (ddlType == "4") {
                    $("#divBrowseLocation").dialog("option", "title", '<span class="header-text">Select Branch</span>');
                    $("#divBrowseLocation").dialog("open");
                    $('#location').dataTable({
                        "oLanguage": {
                            "sZeroRecords": "No records to display",
                            "sSearch": "Search"
                        },
                        "bSort": false,
                        "bPaginate": true,
                        "bAutoWidth": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bDestroy": true,
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bDeferRender": true,
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            $.ajax({
                                "dataType": 'json',
                                "type": "GET",
                                "url": "../Serializer/LocationSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                                "data": aoData,
                                "success": fnCallback
                            });
                        },
                        "aoColumns": [
                        { "mData": "No" },
                        { "mData": "Description" },
                        { "mData": "ORGID" },
                        { "mData": "isActive" },
                        { "mData": "ID" }
                    ],
                        "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickLocation('" + oObj.aData["ID"] + "','" + oObj.aData["Description"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [4]
                        },
                        { "sClass": "center", "aTargets": [0, 2, 3, 4] },
                        { "fnRender":
                            function (oObj) {
                                if (oObj.aData["isActive"] == 'True') {
                                    return "<img src='../images/check.png' />"
                                }
                                else {
                                    return "<img src='../images/cross.png' />"
                                }
                            },
                            "aTargets": [3]
                        }
                    ]
                    });

                    //mark selected row
                    $('body').on("click", '#location tbody tr', function () {
                        $('#location tbody tr').removeClass("row_selected");
                        $(this).addClass("row_selected");
                    });
                    $(".dataTables_filter input").focus();
                }
                else if (ddlType == "5") {
                    $("#divBrowseSubBranch").dialog("option", "title", '<span class="header-text">Select Sub Branch</span>');
                    $("#divBrowseSubBranch").dialog("open");
                    $('#subbranch').dataTable({
                        "oLanguage": {
                            "sZeroRecords": "No records to display",
                            "sSearch": "Search"
                        },
                        "bSort": false,
                        "bPaginate": true,
                        "bAutoWidth": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bDestroy": true,
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bDeferRender": true,
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            $.ajax({
                                "dataType": 'json',
                                "type": "GET",
                                "url": "../Serializer/SubBranchSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                                "data": aoData,
                                "success": fnCallback
                            });
                        },
                        "aoColumns": [
                        { "mData": "No" },
                        { "mData": "Code" },
                        { "mData": "OrgID" },
                        { "mData": "Description" },
                        { "mData": "Branch" },
                        { "mData": "isActive" },
                        { "mData": "ID" }
                    ],
                        "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickSubBranch('" + oObj.aData["ID"] + "','" + oObj.aData["Description"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [6]
                        },
                        { "fnRender":
                            function (oObj) {
                                if (oObj.aData["isActive"] == 'True') {
                                    return "<img src='../images/check.png' />"
                                }
                                else {
                                    return "<img src='../images/cross.png' />"
                                }
                            },
                            "aTargets": [5]
                        },
                        { "sClass": "center", "aTargets": [0, 1, 2, 4, 5, 6] }
                    ]
                    });

                    //mark selected row
                    $('body').on("click", '#subbranch tbody tr', function () {
                        $('#subbranch tbody tr').removeClass("row_selected");
                        $(this).addClass("row_selected");
                    });
                    $(".dataTables_filter input").focus();
                }
                return false;
            });

            PickBusinessGroup = function (BusinessGroupID, BusinessGroupDescription) {
                var counterID = 0;
                $('#tblAssignment tr').each(function () {
                    counterID++;
                });


                var html = "<tr id='1" + counterID + "'><td>" + BusinessGroupDescription + "</td><td>&nbsp;<a onclick='hapusrowBussines(1" + counterID + ")' href='#'>remove</a></td><td> <input type='hidden' name='1" + counterID + "' id='1" + counterID + "' value='" + BusinessGroupID + "' /></td></tr>";
                $("#tblAssignment").append(html);
                $("#divBrowseBusinessGroup").dialog("close");
            }


            $("#btn_BrowseRGMType").click(function () {

                return false;
            });

            PickRGMType = function (RGMTypeID, RGMTypeDescription) {
                var counterID = 0;
                $('#tblAssignmentRgmType tr').each(function () {
                    counterID++;
                });

                var html = "<tr id='2" + counterID + "'><td>" + RGMTypeDescription + "</td><td>&nbsp;<a onclick='hapusrowRgmType(2" + counterID + ")' href='#'>remove</a></td><td> <input type='hidden' name='2" + counterID + "' id='2" + counterID + "' value='" + RGMTypeID + "' /></td></tr>";
                $("#tblAssignment").append(html);
                $("#divBrowseRGMType").dialog("close");
            }

            $("#btn_BrowseRGM").click(function () {

                return false;
            });

            PickRGM = function (RGMID, RGMDescription) {
                var counterID = 0;
                $('#tblAssignmentRgm tr').each(function () {
                    counterID++;
                });

                var html = "<tr id='3" + counterID + "'><td>" + RGMDescription + "</td><td>&nbsp;<a onclick='hapusrowRgm(3" + counterID + ")' href='#'>remove</a></td><td> <input name='3" + counterID + "' type='hidden' id='3" + counterID + "' value='3" + RGMID + "' /></td></tr>";
                $("#tblAssignment").append(html);
                $("#divBrowseRGM").dialog("close");
            }

            $("#btn_BrowseLocation").click(function () {

                return false;
            });

            PickLocation = function (LocationID, LocationDescription) {
                var counterID = 0;
                $('#tblAssignmentBranch tr').each(function () {
                    counterID++;
                });
                var html = "<tr id='4" + counterID + "'><td>" + LocationDescription + "</td><td>&nbsp;<a onclick='hapusrowBranch(4" + counterID + ")' href='#'>remove</a></td><td> <input name='4" + counterID + "' type='hidden' id='4" + counterID + "' value='" + LocationID + "' /></td></tr>";
                $("#tblAssignment").append(html);
                $("#divBrowseLocation").dialog("close");
            }

            //browse subbranch
            $("#btn_BrowseSubBranch").click(function () {

                return false;
            });

            PickSubBranch = function (SubBranchID, SubBranchDescription) {
                var counterID = 0;
                $('#tblAssignmentSubBranch tr').each(function () {
                    counterID++;
                });
                var html = "<tr id='" + counterID + "'><td>" + SubBranchDescription + "</td><td>&nbsp;<a onclick='hapusrowSubBranch(" + counterID + ")' href='#'>remove</a></td><td> <input type='hidden' name='" + counterID + "' id='" + SubBranchID + "' value='" + SubBranchID + "' /></td></tr>";
                $("#tblAssignment").append(html);
                $("#divBrowseSubBranch").dialog("close");
            }
            //end 

            $("#btn_BrowseDivision").click(function () {
                return false;
            });

            PickDivision = function (DivisionID, DivisionDescription) {
                var counterID = 0;
                $('#tblAssignmentDua tr').each(function () {
                    counterID++;
                });
                var html = "<tr id='2" + counterID + "'><td>" + DivisionDescription + "</td><td>&nbsp;<a onclick='hapusrowAssignmentDua(2" + counterID + ")' href='#'>remove</a></td><td> <input type='hidden' name='2" + counterID + "' id='2" + counterID + "' value='" + DivisionID + "' /></td></tr>";
                $("#tblAssignmentDua").append(html);
                $("#divBrowseDivision").dialog("close");
            }

            //browse department
            $("#btn_BrowseDepartment").click(function () {

                return false;
            });

            PickDepartment = function (DepartmentID, DepartmentDescription) {
                var counterID = 0;
                $('#tblAssignmentDua tr').each(function () {
                    counterID++;
                });

                var html = "<tr id='2" + counterID + "'><td>" + DepartmentDescription + "</td><td>&nbsp;<a onclick='hapusrowAssignmentDua(2" + counterID + ")' href='#'>remove</a></td><td> <input type='hidden' name='2" + counterID + "' id='2" + counterID + "' value='" + DepartmentID + "' /></td></tr>";
                $("#tblAssignmentDua").append(html);
                $("#divBrowseDepartment").dialog("close");
                //$("#btn_BrowseSection").attr("disabled", false);
            }
            //end browse department


            hapusrowAssignmentDua = function (id) {
                $("table#tblAssignmentDua tr#" + id).remove();
                return false;
            }

            hapusrowBussines = function (id) {
                $("table#tblAssignment tr#" + id).remove();
                return false;
            }

            hapusrowRgmType = function (id) {
                $("table#tblAssignmentRgmType tr#" + id).remove();
                return false;
            }

            hapusrowRgm = function (id) {
                $("table#tblAssignmentRgm tr#" + id).remove();
                return false;
            }

            hapusrowBranch = function (id) {
                $("table#tblAssignmentBranch tr#" + id).remove();
                return false;
            }

            hapusrowSubBranch = function (id) {
                $("table#tblAssignmentSubBranch tr#" + id).remove();
                return false;
            }

            hapusrowDivision = function (id) {
                $("table#tblAssignmentDivision tr#" + id).remove();
                return false;
            }

            hapusrowDepartment = function (id) {
                $("table#tblAssignmentDepartment tr#" + id).remove();
                return false;
            }
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="rgmformarea" class="ui-widget-content padding5px ui-corner-all">
        <table class="dialogTable">
        <tr>
            <td>
             Group KPI 
            </td>
            <td style="padding-left:10px;" >
                :
            </td>
            <td style="padding-left:10px;">
          
            <asp:Label runat="server" ID="lblGroup" Font-Bold="true" Text=""></asp:Label>
            </td>
            
        </tr>

         <tr>
            <td>
             Category KPI 
            </td>
            <td style="padding-left:10px;">
                :
            </td>
            <td style="padding-left:10px;"><asp:Label runat="server" ID="lblCategory" Font-Bold="true" Text=""></asp:Label></td>
            
        </tr>

         <tr>
            <td>
             Type KPI 
            </td>
            <td style="padding-left:10px;">
                :
            </td>
            <td style="padding-left:10px;"><asp:Label runat="server" ID="lblType" Font-Bold="true" Text=""></asp:Label></td>
            
        </tr>

         <tr>
            <td>
             SubType KPI 
            </td>
            <td style="padding-left:10px;">
                :
            </td>
            <td style="padding-left:10px;"><asp:Label runat="server" ID="lblSub" Font-Bold="true" Text=""></asp:Label></td>
            
        </tr>

        <tr>
            <td>
             KPI 
            </td>
            <td style="padding-left:10px;">
                :
            </td>
            <td style="padding-left:10px;"><asp:Label runat="server" ID="lblKPI" Font-Bold="true" Text=""></asp:Label></td>
            
        </tr>

            <tr>
                <td>
                    Assignment By
                </td>
                <td style="padding-left:10px;">
                    :
                </td>
                <td style="padding-left:10px;">
                    <asp:DropDownList ID="ddlAssigment" runat="server" Width="200">
                        <asp:ListItem Value="1" Text="Business Group"></asp:ListItem>
                        <asp:ListItem Value="2" Text="RGM Type"></asp:ListItem>
                        <asp:ListItem Value="3" Text="RGM"></asp:ListItem>
                        <asp:ListItem Value="4" Text="Branch"></asp:ListItem>
                        <asp:ListItem Value="5" Text="Sub Branch"></asp:ListItem>
                    </asp:DropDownList>
                    <div id="div1" runat="server" style="overflow: auto;">
                        <table id="tblAssignment" border="0" cellpadding="0" cellspacing="0">
                        </table>
                    </div>
                    <button id="btn_BrowseBusinessGroup" class="ui-button ui-state-default">
                        <span class="ui-button ui-icon ui-icon-newwin"></span>
                    </button>
                    <input type="hidden" id="txt_businessgroupid" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    Assignment By
                </td>
                <td style="padding-left:10px;">
                    :
                </td>
                <td style="padding-left:10px;">
                    <asp:DropDownList ID="ddlAssignmentDua" runat="server" Width="200">
                        <asp:ListItem Value="6" Text="Division"></asp:ListItem>
                        <asp:ListItem Value="7" Text="Department"></asp:ListItem>
                    </asp:DropDownList>
                    <div id="div2" runat="server" style="overflow: auto;">
                        <table id="tblAssignmentDua" border="0" cellpadding="0" cellspacing="0">
                        </table>
                    </div>
                    <button id="btn_BrowseBusinessGroupDua" class="ui-button ui-state-default">
                        <span class="ui-button ui-icon ui-icon-newwin"></span>
                    </button>
                    <input type="hidden" id="Hidden1" runat="server" />
                </td>
            </tr>
            <tr>
             <td colspan="3">
             
             </td>
            </tr>
        </table>
    </div>
    <br />
    <div id="divBrowseBusinessGroup" class="ui-widget-content padding5px ui-corner-all">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="businessgroup">
            <thead>
                <tr>
                    <th>
                        No
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        is Active
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <div id="divBrowseRGMType" class="ui-widget-content padding5px ui-corner-all">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="rgmtype">
            <thead>
                <tr>
                    <th>
                        No
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        is Active
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <div id="divBrowseRGM" class="ui-widget-content padding5px ui-corner-all">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="rgm">
            <thead>
                <tr>
                    <th>
                        No
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        is Active
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <div id="divBrowseLocation" class="ui-widget-content padding5px ui-corner-all">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="location">
            <thead>
                <tr>
                    <th>
                        No
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        ORG ID
                    </th>
                    <th>
                        is Active
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <div id="divBrowseSubBranch" class="ui-widget-content padding5px ui-corner-all">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="subbranch">
            <thead>
                <tr>
                    <th>
                        No
                    </th>
                    <th>
                        Code
                    </th>
                    <th>
                        ORG ID
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        Branch
                    </th>
                    <th>
                        is Active
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <div id="divBrowseDivision" class="ui-widget-content padding5px ui-corner-all">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="division">
            <thead>
                <tr>
                    <th>
                        No
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        is Active
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <div id="divBrowseDepartment" class="ui-widget-content padding5px ui-corner-all">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="department">
            <thead>
                <tr>
                    <th>
                        No
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        is Active
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <br />
    <button id="btn_saveassign" class="button save" runat="server" name="btn_saveassign">
        Save
    </button>
    <button id="btn_closeassign" class="button close" runat="server" name="btn_closeassign">
        Close
    </button>
    <%--<button id="btn_delete" class="ui-button ui-corner-all ui-button ui-state-default ui-button-text-icon-primary"
        runat="server">
        <span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span>
        <label class="ui-button-text">
            Delete</label>
    </button>--%>
    <asp:HiddenField ID="hfIdAssign" runat="server"/>
    <asp:HiddenField ID="hfIdDetail" runat="server" Value="0" />
    <asp:HiddenField ID="hfIdDetailDua" runat="server" Value="0" />
    <asp:HiddenField ID="hfIdDetailRgmType" runat="server" Value="0" />
    <asp:HiddenField ID="hfIdDetailRgm" runat="server" Value="0" />
    <asp:HiddenField ID="hfIdDetailBranch" runat="server" Value="0" />
    </form>
</body>
</html>
